
import java.util.List;  
import javax.faces.model.ListDataModel;  
import org.primefaces.model.SelectableDataModel;  


public class UserDataModel extends ListDataModel<Etudiant> implements SelectableDataModel<Etudiant> {    
  
    public UserDataModel() {  
    }  
  
    public UserDataModel(List<Etudiant> data) {  
        super(data);  
    }  
      
    
    public Etudiant getRowData(String rowKey) {  
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data  
          
        List<Etudiant> cars = (List<Etudiant>) getWrappedData();  
          
        for(Etudiant car : cars) {  
            if(car.getUserId()==Long.parseLong(rowKey))  
                return car;  
        }  
          
        return null;  
    }  
  
   
    public Object getRowKey(Etudiant car) {  
        return car.getUserId();  
    }

 
} 